import cv2
import numpy as np

# 读取图像  
image = cv2.imread('imgs/fishcamera.jpg', 0)

# Harris角点检测  
block_size = 2
ksize = 3
k = 0.04
dst = cv2.cornerHarris(image, block_size, ksize, k)

# 阈值处理  
dst = cv2.dilate(dst, None)
thresh = 0.01 * dst.max()
corners = np.uint8(dst > thresh)

# 在原图上标记角点  
image[corners == 255] = [255]  # 因为corners是二值图像，所以只有0和255两个值  

# 显示结果  
cv2.imshow('Harris Corner Detection', image)
cv2.waitKey(0)
cv2.destroyAllWindows()